import 'package:mall/modules/model/category_entity.dart';
import 'package:mall/modules/service/category_service.dart';
import 'package:mall/utils/sc/state_controller.dart';

import '../model/category_title_entity.dart';

class CategoryListSc extends PagingListSC<CategoryEntity>{
  @override
  Future<List<CategoryEntity>> loadData() async{
    final res = await CategoryService.getCategoryData();
    return res;
  }
}

class SubCategoryListSc extends PagingListSC<CategoryEntity>{
  int? categoryId;
  
  @override
  Future<List<CategoryEntity>> loadData() async{
    if (categoryId == null) {
      throw Exception('category id should not be null');
    }

    final res = await CategoryService.getSubCategoryData(categoryId!);
    return res;
  }
}


class CategoryTitleSc extends ModelSC<CategoryTitleEntity> {

  int? categoryId;

  @override
  Future<CategoryTitleEntity?> loadData() async{
     if (categoryId == null) {
      throw Exception('category id should not be null');
    }
    final res = await CategoryService.getCategoryTitle(categoryId!);
    return res;
  }
}